< previous page page_416 next page >

Page 416
serve as a general tool for starting and stopping services. So I came up with the following features:
A list box to display the name and display names of each service. The list box allows multiple selection so that more than one service can be controlled at a time.
Buttons to start and stop one or more services.
A button to restore all services to their original state (as they were when the program launched).
A way to keep track of changes so the utility can prompt whether to restore the services to their original state when the program is closed.
A button to select the IIS services.
Figure T10-2 shows the user interface for the utility.
0416-01.gif
Figure T10-2:
The user interface for the SCToggle application
The program defines a set of variables. The sc variable holds the single ServiceManager object used by the program. The OriginalStates collection holds a group of ServiceStatus objects that are loaded with the original states of the services. The ServiceCollection collection holds a group of ServiceStatus objects reflecting the current state of the services (though it's not always kept up to date, as you'll see). The ChangesInProgress collection holds ServiceObject objects that are in the process of being changed. The Changed variable indicates that you've changed the state of one or more services. The TargetState variable indicates whether you are stopping or starting the services that are being changed or restoring them to their original state:
Dim sc As New ServiceManager

Dim ServiceCollection As Collection ' Hold current states
Dim OriginalStates As Collection    ' Record original states

 
< previous page page_416 next page >